home *** CD-ROM | disk | FTP | other *** search
- (*----------------------------------------------------------------------*)
- (* Init_File --- Initialize File to be listed *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Init_File( VAR File_Spec: AnyStr; VAR CC_Given: AnyStr );
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: Init_File *)
- (* *)
- (* Purpose: Initializes File to be listed *)
- (* *)
- (* Calling sequence: *)
- (* *)
- (* Init_File( VAR File_Spec: AnyStr; VAR CC_Given: AnyStr ); *)
- (* *)
- (* File_Spec: Name of file to be listed. *)
- (* CC_Given: Carriage_control type. *)
- (* *)
- (* Calls: ClrScr *)
- (* Clear_Screen *)
- (* ClrEol *)
- (* Delay *)
- (* Halt *)
- (* GoToXY *)
- (* Reset *)
- (* IOResult *)
- (* Read_Command *)
- (* Skipbl *)
- (* TextMode *)
- (* TextColor *)
- (* Min *)
- (* Max *)
- (* GetFileSpec *)
- (* *)
- (* Remarks: *)
- (* *)
- (* A prompt is issued for the desired file name and its *)
- (* carriage-control characteristics. An empty file causes *)
- (* PibList to halt. *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- OK_File: BOOLEAN;
-
- (*----------------------------------------------------------------------*)
-
- PROCEDURE GetFileSpec;
-
- BEGIN (* GetFileSpec *)
-
- Textcolor( Help_Text_Color );
- ClrScr;
- GoToXY( 5 , 8 );
-
- WRITE('Enter name of file to be listed: ');
-
- (* Read file name *)
- READLN( File_Spec );
-
- (* Check if any file name entered. *)
-
- IF LENGTH(File_Spec) <= 0 THEN
- BEGIN
- TextColor( Help_Text_Color + Blink );
- WRITELN;
- WRITELN(' >>>>> No file name entered, program halts.');
- TextColor( ForeGround_Color );
- Delay( 4000 );
- Clear_Screen;
- Halt;
- END;
-
- END (* GetFileSpec *);
-
- (*----------------------------------------------------------------------*)
-
- BEGIN (* Init_File *)
-
- OK_File := FALSE;
-
- IF LENGTH( File_Spec ) <= 0 THEN (* Prompt for name of file to list *)
- GetFileSpec;
-
-
- REPEAT
- (* Attach file to be listed *)
- Assign( f, File_Spec );
-
- (*$I- *)
- Reset( F );
- (*$I+ *)
-
- IF IOresult <> 0 THEN
- BEGIN
- Textcolor( Help_Text_Color + Blink );
- WRITELN;
- WRITELN(' >>>>> Can''t find file ',File_Spec);
- TextColor( ForeGround_Color );
- Delay( 4000 );
- Clear_Screen;
- GetFileSpec;
- END
- ELSE
- OK_File := TRUE;
-
- UNTIL( OK_File );
- (* Set file for reading *)
- Reset_F;
- (* Pick up FCB address of F *)
- F_Ptr := Addr( F );
-
- (* Empty file -- quit *)
- IF EOF( F ) THEN
- BEGIN
- Textcolor( Help_Text_Color + Blink );
- WRITELN;
- WRITELN(' >>>>> File ', File_Spec,' is empty');
- Textcolor( ForeGround_Color );
- Delay( 4000 );
- Clear_Screen;
- Halt;
- END;
- (* Check up carriage control type *)
-
- IF ( CC_Given <> '' ) AND
- ( CC_Given <> 'LPC' ) AND
- ( CC_Given <> 'FF' ) AND
- ( CC_Given <> 'NONE' ) THEN
- BEGIN
-
- Textcolor( Help_Text_Color );
- GoToXY( 5 , 9 );
- ClrEol;
- WRITE('Enter carriage control characteristics (CC,LIST,NONE)');
-
- Read_Command;
- Skipbl;
-
- CC_Given := '';
-
- WHILE( ( cind <= Max_String ) AND ( command[cind] <> nul ) ) DO
- BEGIN
- CC_Given := CC_Given + UPCASE(command[cind]);
- cind := cind + 1;
- END;
-
- END;
-
- lpt := FALSE;
- nocc := TRUE;
-
- IF CC_Given = 'LPC' THEN
- BEGIN
- lpt := TRUE;
- nocc := FALSE;
- END
- ELSE IF CC_Given = 'FF' THEN
- nocc := FALSE;
-
- END (* Init_File *);
-
- (*----------------------------------------------------------------------*)
- (* Initialize --- Initialize PibList Program *)
- (*----------------------------------------------------------------------*)
-
- PROCEDURE Initialize;
-
- (*----------------------------------------------------------------------*)
- (* *)
- (* Procedure: Initialize *)
- (* *)
- (* Purpose: Initializes PibList program execution *)
- (* *)
- (* Calling sequence: *)
- (* *)
- (* Initialize; *)
- (* *)
- (* Calls: Get_Screen_Address *)
- (* Set_Global_Colors *)
- (* Init_File *)
- (* Read_Line *)
- (* TextMode *)
- (* TextColor *)
- (* Min *)
- (* Max *)
- (* FillChar *)
- (* *)
- (*----------------------------------------------------------------------*)
-
- VAR
- i: INTEGER;
- j: INTEGER;
- k: INTEGER;
- len: INTEGER;
- last_col: INTEGER;
- p: Line_Ptr;
- CC_Given: AnyStr;
- File_Spec: AnyStr;
- Param_Str: AnyStr;
-
- BEGIN (* Initialize *)
-
- Max_line := 0;
- Max_page := 0;
- done := FALSE;
- eod := FALSE;
- lpt := FALSE;
- width := 80;
- Expand_Tabs := FALSE;
- Strip_High := FALSE;
- File_Spec := '';
- CC_Given := '';
- Eject_Char := CHR(255);
-
- spec_chars := [#0..#31,#127];
-
- (* Get the circular text line buffer *)
- NEW( First );
-
- Last := First;
-
- FOR i := 1 TO Max_buf_lines-1 DO
- BEGIN
- NEW( p );
- last^.next := p;
- last := p
- END;
-
- last^.next := first;
- last := nil;
-
- (* Select color/mono screen *)
-
- Get_Screen_Address( Real_Screen );
-
- (* Establish colors *)
-
- IF Color_Screen_Active THEN
- BEGIN
-
- ForeGround_Color := Yellow (* Color for ordinary text *);
- BackGround_Color := Black (* Usual background color *);
-
- Help_Text_Color := Red (* Color for help text *);
- Spec_Chars_Color := Green (* Color for spec. chars *);
- Status_Line_Color := Blue (* Status line color *);
- Search_Text_Color := Green (* Color for searched text *);
-
- TextMode ( C80 );
-
- END
- ELSE
- BEGIN
-
- ForeGround_Color := White (* Color for ordinary text *);
- BackGround_Color := Black (* Usual background color *);
-
- Help_Text_Color := White (* Color for help text *);
- Spec_Chars_Color := White (* Color for spec. chars *);
- Status_Line_Color := Black (* Color for status line *);
- Search_Text_Color := White + 128 (* Color for searched text *);
-
- TextMode ( BW80 );
-
- END;
-
- Set_Global_Colors( ForeGround_Color, BackGround_Color );
-
- TextColor( ForeGround_Color );
- TextBackGround( BackGround_Color );
-
- (* Scan for parameters *)
-
- FOR I := 1 TO ParamCount DO
- BEGIN
-
- Param_Str := ParamStr( I );
-
- IF Param_Str[1] <> '/' THEN
- File_Spec := Param_Str
- ELSE
-
- CASE UpCase( Param_Str[2] ) OF
-
- 'T': Expand_Tabs := TRUE;
- 'H': Strip_High := TRUE;
- 'L': IF UpCase( Param_Str[3] ) = 'P' THEN
- CC_Given := 'LPC';
- 'F': IF UpCase( Param_Str[3] ) = 'F' THEN
- CC_Given := 'FF';
-
- ELSE ;
-
- END (* CASE *);
-
- END;
-
- (* Get the file name to list and open it *)
-
- Init_file( File_Spec , CC_Given );
-
- (* Choose FF or '1' as page marker *)
-
- IF ( NOT nocc ) THEN
- IF lpt THEN eject_char := '1' ELSE eject_char := FF;
-
- i := 1;
- last_col := 1;
- (* Read in the first Max_Buf_Lines lines *)
- REPEAT
-
- Read_Line;
-
- i := i + 1;
-
- last_col := MAX( last_col , LENGTH( last^.Txt ) );
-
- UNTIL ( i = Max_buf_lines ) OR EOF( F );
-
- Top := First;
-
- IF lpt THEN j := 2 ELSE j := 1;
-
- IF last_col <= width THEN
- first_col := j
- ELSE
- BEGIN
-
- p := first;
- k := Max_String + 1;
-
- REPEAT
-
- i := j;
-
- WITH p^ DO
- BEGIN
-
- len := LENGTH( p^.Txt );
-
- WHILE ( i < len ) AND ( txt[i] IN [' ',ff] ) DO i := i + 1;
-
- IF i < len THEN k := MIN( k , i )
-
- END;
-
- p := p^.next
-
- UNTIL p = last^.next;
-
- first_col := MIN( k , last_col + j - width );
-
- END;
-
- (* No current search string *)
- Search_Str := '';
- Search_Line := 0;
- Search_Lpos := 0;
- Search_Col := 0;
-
- One_Up := FALSE;
- One_Down := FALSE;
-
- END (* Initialize *);